<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>link_inputs &mdash; GSLab Make 2.0.0 documentation</title>
      <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
      <link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/sphinx_highlight.js"></script>
    <script src="../../../_static/js/theme.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
    <link rel="next" title="Source logging functions" href="../../source_logging.html" />
    <link rel="prev" title="link_externals" href="gslab_make.move_sources.link_externals.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="../../../index.html" class="icon icon-home">
            GSLab Make
          </a>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <p class="caption" role="heading"><span class="caption-text">Documentation</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../specifying_paths.html">Specifying paths</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../general_logging.html">General logging functions</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../sourcing.html">Sourcing functions</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="gslab_make.move_sources.copy_externals.html">copy_externals</a></li>
<li class="toctree-l2"><a class="reference internal" href="gslab_make.move_sources.copy_inputs.html">copy_inputs</a></li>
<li class="toctree-l2"><a class="reference internal" href="gslab_make.move_sources.link_externals.html">link_externals</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">link_inputs</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#gslab_make.move_sources.link_inputs"><code class="docutils literal notranslate"><span class="pre">link_inputs()</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../source_logging.html">Source logging functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../program.html">Program functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../utility.html">Utility functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../repository.html">Repository functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../directory.html">Directory functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../filling.html">Filling functions</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">GSLab Make</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../../index.html" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../../sourcing.html">Sourcing functions</a></li>
      <li class="breadcrumb-item active">link_inputs</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../../_sources/pages/api/move_sources/gslab_make.move_sources.link_inputs.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section id="link-inputs">
<h1>link_inputs<a class="headerlink" href="#link-inputs" title="Permalink to this heading"></a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="gslab_make.move_sources.link_inputs">
<span class="sig-name descname"><span class="pre">link_inputs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">paths</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">file_list</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gslab_make.move_sources.link_inputs" title="Permalink to this definition"></a></dt>
<dd><p>Create symbolic links using instructions contained in files of list <code class="docutils literal notranslate"><span class="pre">file_list</span></code>.
Instructions are <a class="reference external" href="https://docs.python.org/3.4/library/string.html#format-string-syntax">string formatted</a>
using paths dictionary <code class="docutils literal notranslate"><span class="pre">paths</span></code>. Symbolic links are written in directory <code class="docutils literal notranslate"><span class="pre">input_dir</span></code>.
Status messages are appended to file <code class="docutils literal notranslate"><span class="pre">makelog</span></code>.</p>
<p>Instruction files on how to create symbolic links (destinations) from targets (sources)
should be formatted in the following way.</p>
<div class="highlight-md notranslate"><div class="highlight"><pre><span></span><span class="gh"># Each line of instruction should contain a destination and source delimited by a `|`</span>
<span class="gh"># Lines beginning with # are ignored</span>
destination | source
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Symbolic links can be created to both files and directories.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Instruction files can be specified with the * shell pattern
(see <a class="reference external" href="https://www.gnu.org/software/findutils/manual/html_node/find_html/Shell-Pattern-Matching.html">here</a>).
Destinations and their sources can also be specified with the * shell pattern.
The number of wildcards must be the same for both destinations and sources.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>paths</strong> (<em>dict</em>) – Dictionary of paths. Dictionary should contain values for all keys listed below.
Dictionary additionally used to string format linking instructions.</p></li>
<li><p><strong>file_list</strong> (<em>str</em><em>, </em><em>list</em>) – File or list of files containing linking instructions.</p></li>
</ul>
</dd>
<dt class="field-even">Path Keys<span class="colon">:</span></dt>
<dd class="field-even"><ul class="simple">
<li><p><strong>input_dir</strong> (<em>str</em>) – Directory to write symlinks.</p></li>
<li><p><strong>makelog</strong> (<em>str</em>) – Path of makelog.</p></li>
</ul>
</dd>
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>source_map</strong> – List of (source, destination) for each symlink created.</p>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p>list</p>
</dd>
</dl>
<p class="rubric">Example</p>
<p>Suppose you call the following function.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">link_inputs</span><span class="p">(</span><span class="n">paths</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;file1&#39;</span><span class="p">],</span> <span class="n">formatting_dict</span><span class="p">)</span>
</pre></div>
</div>
<p>Suppose <code class="docutils literal notranslate"><span class="pre">paths</span></code> contained the following values.</p>
<div class="highlight-md notranslate"><div class="highlight"><pre><span></span>paths = {&#39;root&#39;: &#39;/User/root/&#39;,
         &#39;makelog&#39;: &#39;make.log&#39;,
         &#39;input_dir&#39;: &#39;input&#39;}
</pre></div>
</div>
<p>Now suppose instruction file <code class="docutils literal notranslate"><span class="pre">file1</span></code> contained the following text.</p>
<div class="highlight-md notranslate"><div class="highlight"><pre><span></span>destination1 | {root}/source1
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">{root}</span></code> in the instruction file would be string formatted using <code class="docutils literal notranslate"><span class="pre">paths</span></code>.
Therefore, the function would parse the instruction as:</p>
<div class="highlight-md notranslate"><div class="highlight"><pre><span></span>destination1 | /User/root/source1
</pre></div>
</div>
<p class="rubric">Example</p>
<p>The following code would use instruction files <code class="docutils literal notranslate"><span class="pre">file1</span></code> and <code class="docutils literal notranslate"><span class="pre">file2</span></code> to create symbolic links.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">link_inputs</span><span class="p">(</span><span class="n">paths</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;file1&#39;</span><span class="p">,</span> <span class="s1">&#39;file2&#39;</span><span class="p">])</span>
</pre></div>
</div>
<p>Suppose instruction file <code class="docutils literal notranslate"><span class="pre">file1</span></code> contained the following text.</p>
<div class="highlight-md notranslate"><div class="highlight"><pre><span></span>destination1 | source1
destination2 | source2
</pre></div>
</div>
<p>Symbolic links <code class="docutils literal notranslate"><span class="pre">destination1</span></code> and <code class="docutils literal notranslate"><span class="pre">destination1</span></code> would be created in directory <code class="docutils literal notranslate"><span class="pre">paths['input_dir']</span></code>.
Their targets would be <code class="docutils literal notranslate"><span class="pre">source1</span></code> and <code class="docutils literal notranslate"><span class="pre">source2</span></code>, respectively.</p>
<p class="rubric">Example</p>
<p>Suppose you have the following targets.</p>
<div class="highlight-md notranslate"><div class="highlight"><pre><span></span>source1
source2
source3
</pre></div>
</div>
<p>Specifying <code class="docutils literal notranslate"><span class="pre">destination*</span> <span class="pre">|</span> <span class="pre">source*</span></code> in one of your instruction files would
create the following symbolic links in <code class="docutils literal notranslate"><span class="pre">paths['input_dir']</span></code>.</p>
<div class="highlight-md notranslate"><div class="highlight"><pre><span></span>destination1
destination2
destination3
</pre></div>
</div>
</dd></dl>

</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="gslab_make.move_sources.link_externals.html" class="btn btn-neutral float-left" title="link_externals" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../../source_logging.html" class="btn btn-neutral float-right" title="Source logging functions" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2023, Matthew Gentzkow.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>